package com.erlinyou.im.dao.repository.motion;

import java.util.List;
import java.util.Map;

import org.springframework.data.jpa.repository.Query;

import com.erlinyou.base.dao.BaseRepository;
import com.erlinyou.im.model.motion.UserMotionLike;
import com.erlinyou.im.model.motion.UserMotionLikeKey;

public interface UserMotionLikeRepository extends BaseRepository<UserMotionLike, UserMotionLikeKey>{

	@Query(value="SELECT userid from user_motion_like WHERE zuserid=?1 and createDate=?2",nativeQuery=true)
	List<Long> getMotionLikeByZuserid(Long userid, String createDate);

	//SELECT userid,COUNT(*) AS count from user_motion_like where FIND_IN_SET(userid,?1) GROUP BY userid
	@Query(value="SELECT zuserid,COUNT(*) AS count from user_motion_like where FIND_IN_SET(zuserid,?1) AND createDate = ?2 GROUP BY zuserid",nativeQuery=true)
	List<Map<String, Object>> countByUserid(String ids,Long createDate);

	@Query(value="SELECT * from user_motion_like where zuserid = ?1 and createDate = ?2",nativeQuery=true)
	List<UserMotionLike> findByUseridAndCreateDate(Long userid, Long createDate);

	@Query(value="SELECT zuserid FROM user_motion_like where userid = ?1 AND createDate = ?2",nativeQuery=true)
	List<Map<String, Object>> iSLike(Long userid, Long createDate);

}
